<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
<title>Insert title here</title>
<%@ include file="../mobileHeader_inc.jsp" %>
<script type="text/javascript">
	var pageArray = [];
	var allCount;//获取总记录条数
	var allPage;//计算出总共页数
	var currentPage = 1;//设置当前页
	var rows = 5;//设置每页列数
	$(document).on('pageinit', function () {
		loadMsg(1);
    
	});
	function loadMsg(page){
		currentPage = page;
		var create_Time;
		var msgId;
		$.ajax({
	        url: '${ctx}/mobile/getLostAndFound?page='+page+'&rows='+rows+'',
	        dataType: "json",
	        async: true,
	        success: function (result) {
	        	//分页相关
	        	allCount =  result.rows;
	        	allPage  = Math.ceil(allCount/rows);//总页数
	        	var upPage;//上一页
	        	if(currentPage-1 <= 0){
	        		upPage = 1;
	        	}else{
	        		upPage = currentPage-1;
	        	}
	        	var downPage;//下一页
	        	if(currentPage+1 > allPage){
	        		downPage = allPage;
	        	}else{
	        		downPage = currentPage+1;
	        	}
	        	$("#top_count_num").empty();
	        	$("#count_num").empty();
	        	
	        	var down_need_num = "  <ul data-am-widget='pagination' class='am-pagination am-pagination-default' > </ul>";
	        	$("#count_num").append(down_need_num);
	        	for(var i=1;i<=allPage;i++){
	        		pageArray[i] = i;
	        		ulNum = "<li class=''><a href='#' class='am-active' onclick='loadMsg("+pageArray[i]+");' target='_self' >"+pageArray[i]+"</a></li>";
	    			$("#count_num ul").append(ulNum);
	    		}
	        	$("#product").empty();
	        	if(result.obj != null){
	        		var content = new Array();
	        		for(var i=0;i<result.obj.length;i++){
	        			create_Time = formatDate(result.obj[i].releaseTime);
	        			msgId = result.obj[i].arcitleId;
	        			content[i] = "<li class='am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left'> <div class='am-u-sm-4 am-list-thumb'> <a href='/mobile/goLAFDetail?id="+msgId+"' target='_self' class=''> <img height='100px' src='"+result.obj[i].lafIcon+"'  alt='失物招领图缩略图'/></a></div> <div class=' am-u-sm-8 am-list-main'><h3 class='am-list-item-hd'><a href='/mobile/goLAFDetail?id="+msgId+"' target='_self' class=''> "+result.obj[i].arcitleName+"</a></h3><div class='am-list-item-text'>"+result.obj[i].iteminform+"</div><div class='am-list-item-text'>"+create_Time+"</div></div></li> ";	        	
		        	}
	        		$("#product").empty();
	        		$("#product").append("<div class='am-list-news-bd'><ul class='am-list'>"+content.join(" ")+"</ul></div>");
	        	}
	        },
	        error: function (request, error) {
	        	$("#doc-scrollspy-wrapper").append("<div class='am-alert'> 暂时没有帮助信息哦 ！ </div>");
	        }
	        
	    });
	}
	//格式化日期
	function formatDate (strTime) {
	    var date = new Date(strTime);
	    return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
	}
</script>
</head>
<body style="background-color: #FFFAF0">
<!-- 头部 --> 
<div>
	<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">市场</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#">招领的战场</a></li>
        <li><a href="#">丢失的遗忘</a></li>
      </ul>
      
      <form class="navbar-form navbar-left">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="搜寻你的过往">
        </div>
        <button type="submit" class="btn btn-default">一键搜~</button>
      </form>
      
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
</div>

<!-- 中间 --> 
 <div class="list-content">
		<div id="product" data-am-widget="list_news" class="am-list-news am-list-news-default">
		</div>  
		<!-- 分页 -->
		<div id="count_num">
		</div>
 <ul data-am-widget="pagination" class="am-pagination am-pagination-default">  
  <div data-am-widget="gotop" class="am-gotop am-gotop-default" >
    <a href="#top" title="回到顶部">
        <span class="am-gotop-title">回到顶部</span>
          <i class="am-gotop-icon am-icon-chevron-up"></i>
    </a>
  </div>
   </ul>
   </div>

<!-- 底部 --> 
<div data-am-widget="navbar" class="am-navbar  am-navbar-default gm-foot" id="">
		<ul class="am-navbar-nav am-cf am-avg-sm-4">
		<li ><a href="/manage/index?dep=1" target="_self" class="curr"> <span class="am-icon-home am-navbar-label001"></span> <span class="am-navbar-label">市场</span> </a></li>
		
		<li > <a href="/mobile/personal" target="_self" class="curr"> <span class="am-icon-user"></span> <span class="am-navbar-label">发布</span> </a> </li>
		</ul> 
</div>
</body>
</html>